package cn.mulanbay.persistent.enums;

/**
 * 性别
 *
 * @author fenghong
 * @create 2022-01-16 10:00
 */
public enum Sex {

    F(0, "女"),
    M(1, "男");

    private int value;

    private String name;

    Sex(int value, String name) {
        this.value = value;
        this.name = name;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据value类型转换为enum
     * @param value
     * @return
     */
    public static Sex getEnum(int value) {
        for (Sex bt : Sex.values()) {
            if (bt.getValue() == value) {
                return bt;
            }
        }
        return null;
    }
}
